<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
       .box{
            width: 500px;
            height: 400px;
            border: 1px solid;
            position: relative;
        }

        .box .title{
            width: 100%;
            text-align: center;
            font-size: 18px;
            margin: 10px;
        }

        .price{
            font-size: 20px;
            font-weight: 700;
            width: 100%;
            text-align: center;
            margin: 10px;
        }

        .box .buy{
            width: 100%;
            margin: 10px;
        }

        .buy button{
            position:relative;
            left: 200px;
            justify-content: end;
        }

        .bill{
            width: 100%;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="box">
            <div class="title">欢迎光临水果店</div>

            <div class="price">苹果{{single}}￥/斤，折扣<{{zhekou}}折></div>

            <div class="want" style="width: 100%; text-align: center; margin: 10px;">
                请输入你要购买的斤数
                <input v-model="num" type="text">
            </div>
            <div class="buy">
                <button @click="appleTotal">结账买单</button>
            </div>

            <div class="bill">
                结账单：总价{{total}}￥ 折后价{{after}}￥元 省了:{{save}}￥元
            </div>
        </div>
    </div>

    <script src="../vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data:{
                num:'',
                single:10,
                zhekou:8,
                total:'',
                after:'',
                save:''
            },
            methods:{
                appleTotal(){
                    this.total=this.num*this.single
                    this.after=this.total*0.8
                    this.save=this.total-this.after
                }
            }
        })
    </script>

</body>
</html>